package demoMod.nanaki.cards.nanaki;

import com.megacrit.cardcrawl.actions.common.DrawCardAction;
import com.megacrit.cardcrawl.actions.common.GainEnergyAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.localization.CardStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import demoMod.nanaki.NanakiMod;
import demoMod.nanaki.actions.StruckUpAction;
import demoMod.nanaki.stances.AbstractStrophe;

public class Rhythm extends AbstractNanakiCard {
    public static final String ID = NanakiMod.makeID("Rhythm");

    private static final CardStrings cardStrings = CardCrawlGame.languagePack.getCardStrings(ID);
    public static final String NAME = cardStrings.NAME;
    public static final String DESCRIPTION = cardStrings.DESCRIPTION;
    public static final String IMG_PATH = "cards/Rhythm";

    private static final CardType TYPE = CardType.SKILL;
    private static final CardRarity RARITY = CardRarity.RARE;
    private static final CardTarget TARGET = CardTarget.NONE;

    private static final int COST = 0;

    public Rhythm() {
        super(ID, NAME, NanakiMod.getResourcePath(IMG_PATH), COST, DESCRIPTION, TYPE, RARITY, TARGET);
        this.exhaust = true;
    }

    @Override
    public Runnable getUpgradeAction() {
        return () -> {
            this.rawDescription = cardStrings.UPGRADE_DESCRIPTION;
            this.initializeDescription();
        };
    }

    @Override
    public void triggerOnGlowCheck() {
        this.glowColor = AbstractCard.BLUE_BORDER_GLOW_COLOR.cpy();
        AbstractPlayer p = AbstractDungeon.player;
        if (p.stance instanceof AbstractStrophe) {
            this.glowColor = AbstractCard.GOLD_BORDER_GLOW_COLOR.cpy();
        }
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        addToBot(new DrawCardAction(upgraded ? 2 : 1));
        if (p.stance instanceof AbstractStrophe) {
            AbstractStrophe strophe = (AbstractStrophe) p.stance;
            if (strophe.getStropheLevel() >= 1) {
                addToBot(new GainEnergyAction(1));
            }
            if (strophe.getStropheLevel() >= 2) {
                addToBot(new DrawCardAction(1));
            }
            if (strophe.getStropheLevel() >= 3) {
                addToBot(new StruckUpAction());
            }
        }
    }
}
